package com.itheima.morning.demo03;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

@Pro(className = "com.itheima.morning.demo03.Dog",methodName = "eat")
public class DemoClass {
    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
        Class<DemoClass> cla = DemoClass.class;

        Pro annotation = cla.getAnnotation(Pro.class);

        String className = annotation.className();
        String methodName = annotation.methodName();

        Class clazz = Class.forName(className);
        Object o = clazz.getConstructor().newInstance();
        Method method = clazz.getMethod(methodName);
        method.invoke(o);
    }
}
